home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 2007-11-24 | 44.0 KB | 1,058 lines
using System; using System.Diagnostics; using System.Globalization; using System.IO; using System.Net; using System.Web; using System.Web.UI; using GBPVR.Public; using GBPVRSchedule; using gbweb.classes; namespace gbweb { public partial class Player : Page { private Settings guideParams; private string serverAddr; private Process proc; private ProcessStartInfo psi; protected void Page_Load(object sender, EventArgs e) { getTheme(); if (!IsPostBack) { //Kill any running VLC processes killVLC(); playerOptions.Visible = true; transConfigOptions.Visible = true; transcodeOptions.Visible = false; controlTable.Visible = false; buttonTable.Visible = false; resetButton_Click(null, null); } } private void AddKeepAlive() { //Routine to keep session alive int int_MilliSecondsTimeOut = (Session.Timeout * 60000) - 30000; string str_Script = @" <script type='text/javascript'> //Number of Reconnects var count=0; //Maximum reconnects setting var max = 5; window.status = 'Auto Reconnect Script is Activated' function Reconnect(){ count++; if (count < max) { window.status = 'Link to Server Refreshed ' + count.toString()+' time(s)' ; var img = new Image(1,1); img.src = 'keepalive.aspx'; } } window.setInterval('Reconnect()'," + int_MilliSecondsTimeOut.ToString() + @"); //Set to length required </script> "; ClientScript.RegisterStartupScript(typeof(String), "Reconnect", str_Script, false); } private void AddPlayerScript() { //Insert script to the client to play the VLC Plugin int int_MilliSecondsTimeOut = (Session.Timeout * 60000) - 30000; string options = ""; string str_Script = ""; //Determine correct VLC Profile int vlcProfile = GetVlcProfile(); VLCCommon VLC = new VLCCommon(vlcProfile); if (VLC.strmPlayer == "vlc") { if (Request.ServerVariables["HTTP_USER_AGENT"].IndexOf("MSIE") > 0) { str_Script = @" <script> window.status = 'Play Stream Activated' function playVideo() { var options = new Array('http-caching="; str_Script += VLC.strmBuffer; str_Script += @"'); "; string location = "document.video1.addTarget('http://" + serverAddr + "', options , 4+8, -666);"; str_Script += location; str_Script += @" window.status = 'Play Button Clicked'; document.video1.play(); } </script> "; } else { str_Script = @" <script> function playVideo() { document.video1.play(); } </script> "; } } ClientScript.RegisterStartupScript(typeof(String), "playVideo", str_Script, false); } public string getIP() { //Alternative method for obtaining external IP if it can not be obtained by Request.Servervariables WebClient wclient = new WebClient(); wclient.DownloadFile("http://www.whatismyip.com/", Request.MapPath("ip.txt")); FileStream FS = new FileStream(Request.MapPath("ip.txt"), FileMode.Open); StreamReader SR = new StreamReader(FS); string entirefile = SR.ReadToEnd(); int startIndex = entirefile.IndexOf("<h1>Your IP"); int endIndex = entirefile.IndexOf("</", startIndex); string restOfTheLine = entirefile.Substring(startIndex + 15, (endIndex - startIndex - 15)); string theIp = restOfTheLine.TrimEnd("<>brh1 ".ToCharArray()); SR.Close(); FS.Close(); File.Delete(Request.MapPath("ip.txt")); return theIp.Trim(); } private void doPlay() { //Process to launch VLC on server to stream video string filename = GetFilename(); //Develop list of arguments to be passed to VLC on the server string args; //Instantiate a VLC instance defaulted to correct profile int vlcProfile = GetVlcProfile(); VLCCommon VLC = new VLCCommon(vlcProfile); if (VLC.getStrmSetting() == "manual") { if (VLC.getStrmVEncoder() == "h264") { //Instantiate H264 object to profile 1 (video) H264Encoder H264Enc = new H264Encoder(vlcProfile); args = VLC.genCommandLine(filename, VLC, H264Enc); } else { args = VLC.genCommandLine(filename, VLC); } } else { args = VLC.genCommandLine(filename, VLC.getStrmSetting(),VLC.getStrmVideoSize(), VLC.getStrmMux(), VLC.getStrmBitRate(), VLC.getStrmPort()); } //Log what is being started on the server Logger.Info("***********************"); Logger.Info("VLC Path= " + VLC.strmVLCLoc); Logger.Info("Args= " + args); //Build the process that will run VLC on the server psi = new ProcessStartInfo(VLC.getVLCLoc() + "vlc.exe", args); psi.UseShellExecute = false; psi.RedirectStandardError = false; psi.RedirectStandardInput = false; psi.RedirectStandardOutput = false; //Start the VLC process on the server proc = Process.Start(psi); //Set the priority of the started process based off of user configuration switch(VLC.getStrmPriority().ToUpper()) { case "BELOWNORMAL": proc.PriorityClass = ProcessPriorityClass.BelowNormal; break; case "ABOVENORMAL": proc.PriorityClass = ProcessPriorityClass.AboveNormal; break; case "NORMAL": proc.PriorityClass = ProcessPriorityClass.Normal; break; case "HIGH": proc.PriorityClass = ProcessPriorityClass.High; break; default: proc.PriorityClass = ProcessPriorityClass.Normal; break; } } private string GetFilename() { //Setup schedule to obtain program info to stream Schedule scheduleHelper = Global.Schedule; string filename = ""; //Search/pull the filename of the passed recording if (Request.Params["rid"] != null) { ScheduledRecording scheduledRecording = scheduleHelper.GetScheduledRecordingByOID(Convert.ToInt32(Request.Params["rid"])); if (scheduledRecording != null) { filename = scheduledRecording.getFileName(); } } else { //We are accessing either a Music of Video Library item if (Request.Params["mvid"] != null) { string path = (string)PublicDownload.Deseralize(Request.Params["mvid"]); filename = Library.GetRealPath(path); Logger.Info("***********************"); Logger.Info("File Name Deserialized: " + filename); } else { //We are accessing an entire directory of music or videos if (Request.Params["mid"] != null) { string path = (string) PublicDownload.Deseralize((string)Request.Params["mid"]); string tmpDir = Environment.GetEnvironmentVariable("ALLUSERSPROFILE"); filename = Path.Combine(tmpDir, Download.streamLibraryFolder(Request, path)); Logger.Info("***********************"); Logger.Info("File Location Deserialized: " + filename); } } } return filename; } protected void extButton_Click(object sender, EventArgs e) { guideParams = Global.Settings; string serverIP = Request.ServerVariables["http_host"]; int index = serverIP.IndexOf(":"); if (index > -1) serverIP = serverIP.Substring(0, index).Trim(); if ((serverIP == null) || (serverIP.Length < 1)) serverIP = getIP(); //Create the address the stream will be available on serverAddr = serverIP + ":" + guideParams.strmPort; //Instantiate a VLC instance set to appropriate profile int vlcProfile = GetVlcProfile(); VLCCommon VLC = new VLCCommon(vlcProfile); if (VLC.strmPlayer != "dnld") { //Launch VLC External player if (VLC.strmPlayer == "vlc") { Response.AddHeader("Content-Type", "video/mpeg4"); Response.AddHeader("Content-Disposition", "attachment; filename=\"stream.vlc\""); Response.Write("#EXTM3U\r\n"); Response.Write("http://" + serverAddr + "\n"); Response.End(); } else //Launch Windows Media Player (as long as ASF is associated to Windows Media) { Response.AddHeader("Content-Type", "video/x-ms-asf"); Response.AddHeader("Content-Disposition", "attachment; filename=\"stream.asx\""); Response.Write("http://" + serverAddr + "\n"); Response.End(); } } else { //We are accessing either a Music of Video Library item. We have seperate settings for each type. Response.AddHeader("Content-Type", "text/plain"); string filename = GetFilename(); Response.AddHeader("Content-Disposition", "attachment; filename=\"download_stream.bat\""); string dnldFile = " --sout file/raw:\"%HOMEDRIVE%%HOMEPATH%\\" + filename.Substring(filename.LastIndexOf("\\") + 1, ((filename.Length - 1) - filename.LastIndexOf("\\"))); //set file extension of downloaded file based on profile switch (vlcProfile) { //Profile 1 is the video profile case 1: switch (streamSetting.SelectedValue) { case "0": dnldFile += ".mpg\""; break; case "1": dnldFile += ".wmv\""; break; case "2": dnldFile += ".wmv\""; break; case "3": dnldFile += ".mpg\""; break; case "manual": switch (VLC.strmVideo) { case "WMV1": dnldFile += ".wmv\""; break; case "WMV2": dnldFile += ".wmv\""; break; default: dnldFile += ".mpg\""; break; } break; default: dnldFile += ".mpg\""; break; } break; //Profile 2 is the audio profile case 2: switch (streamSetting.SelectedValue) { //since all the pre-config settings result in .mpg extension we only need to look at //the manaul setting case "manual": switch (VLC.strmAudio) { case "mp4a": dnldFile += ".mp4\""; break; case "mp3": dnldFile += ".mp3\""; break; default: dnldFile += ".mpg\""; break; } break; default: dnldFile += ".mpg\""; break; } break; //Catch all.....we will handle the file as Profile 1 (video) default: switch (streamSetting.SelectedValue) { case "0": dnldFile += ".mpg\""; break; case "1": dnldFile += ".wmv\""; break; case "2": dnldFile += ".wmv\""; break; case "3": dnldFile += ".mpg\""; break; case "manual": switch (VLC.strmVideo) { case "WMV1": dnldFile += ".wmv\""; break; case "WMV2": dnldFile += ".wmv\""; break; default: dnldFile += ".mpg\""; break; } break; default: dnldFile += ".mpg\""; break; } break; } //Response.Write("\"" + VLC.getVLCLoc() + "vlc.exe\" " + "http://" + serverAddr + " --sout file/raw:\"" + filename.Substring(filename.LastIndexOf("\\") + 1, ((filename.Length - 1) - filename.LastIndexOf("\\"))) + ".mpg\""); Response.Write("\"" + VLC.getVLCLoc() + "vlc.exe\" " + "http://" + serverAddr + dnldFile); Response.End(); } } private static void killVLC() { // kill any existing VLC processes try { foreach (Process thisproc in Process.GetProcessesByName("vlc")) { thisproc.Kill(); } } catch(Exception Exc) { } } //Method that makes VLC on the server skip forward 10 seconds on the currently playing item protected void skipForwardStream(object sender, EventArgs e) { StreamerPost strmPost = new StreamerPost(); strmPost.Url = "http://localhost:8080/"; strmPost.PostItems.Add("seek_value", "+10sec"); strmPost.PostItems.Add("control", "seek"); strmPost.Type = StreamerPost.PostTypeEnum.Get; string result = strmPost.Post(); result = String.Empty; } //Method that makes VLC on the server skip backward 10 seconds on the currently playing item protected void skipBackwardStream(object sender, EventArgs e) { StreamerPost strmPost = new StreamerPost(); strmPost.Url = "http://localhost:8080/"; strmPost.PostItems.Add("seek_value", "-10sec"); strmPost.PostItems.Add("control", "seek"); strmPost.Type = StreamerPost.PostTypeEnum.Get; string result = strmPost.Post(); result = String.Empty; } //Method that makes VLC on the server skip to the next item in the playlist protected void nextStream(object sender, EventArgs e) { StreamerPost strmPost = new StreamerPost(); strmPost.Url = "http://localhost:8080/"; strmPost.PostItems.Add("control","next"); strmPost.Type = StreamerPost.PostTypeEnum.Get; string result = strmPost.Post(); result = String.Empty; } //Method that makes VLC on the server skip back to the previous item in the playlist protected void previousStream(object sender, EventArgs e) { StreamerPost strmPost = new StreamerPost(); strmPost.Url = "http://localhost:8080/"; strmPost.PostItems.Add("control", "previous"); strmPost.Type = StreamerPost.PostTypeEnum.Get; string result = strmPost.Post(); result = String.Empty; } //Method that makes VLC on the server stop playing protected void stopStream(object sender, EventArgs e) { StreamerPost strmPost = new StreamerPost(); strmPost.Url = "http://localhost:8080/"; strmPost.PostItems.Add("control", "stop"); strmPost.Type = StreamerPost.PostTypeEnum.Get; string result = strmPost.Post(); result = String.Empty; } //Method that makes VLC on the server start to play the playlist protected void playStream(object sender, EventArgs e) { StreamerPost strmPost = new StreamerPost(); strmPost.Url = "http://localhost:8080/"; strmPost.PostItems.Add("control", "play"); strmPost.Type = StreamerPost.PostTypeEnum.Get; string result = strmPost.Post(); result = String.Empty; } //Method that makes VLC on the server pause playing of the currently playing item protected void pauseStream(object sender, EventArgs e) { StreamerPost strmPost = new StreamerPost(); strmPost.Url = "http://localhost:8080/"; strmPost.PostItems.Add("control", "pause"); strmPost.Type = StreamerPost.PostTypeEnum.Get; string result = strmPost.Post(); result = String.Empty; } //Method that Kills the VLC process on the server protected void stopStreamer(object sender, EventArgs e) { //Kill the VLC process on the server killVLC(); //If we were streaming via the Stream Now option we need to get rid of the recording if (Request.Params["rid"] != null && Request.Params["type"] != null) { if (Request.Params["type"] == "sn") { Schedule scheduleHelper = Global.Schedule; ScheduledRecording scheduledRecording = scheduleHelper.GetScheduledRecordingByOID(Convert.ToInt32(Request.Params["rid"])); if (scheduledRecording != null) { scheduleHelper.CancelScheduledRecording(scheduledRecording); scheduledRecording = scheduleHelper.GetScheduledRecordingByOID(Convert.ToInt32(Request.Params["rid"])); scheduleHelper.CancelScheduledRecording(scheduledRecording); } } } //Close the player window ClientScript.RegisterStartupScript(typeof(String), "closeScript", "<script language=JavaScript>popupClose();</script>", false); } protected void resetButton_Click(object sender, EventArgs e) { //Load settings guideParams = Global.Settings; //Instantiate a VLC instance defaulted to correct profile int vlcProfile = GetVlcProfile(); VLCCommon VLC = new VLCCommon(vlcProfile); //Web Streamer VLC Common Class streamPlayer.Text = VLC.getPlayer(); //Need to set the appropriate pre-configed options on the page based on player selection streamPlayer_SelectedIndexChanged(null, null); externalPlayer.Checked = VLC.strmExternal; streamPort.Text = VLC.getStrmPort().ToString(); streamBuffer.Text = VLC.getStrmBuffer().ToString(); streamPriority.Text = VLC.getStrmPriority(); streamBitRate.Text = VLC.getStrmBitRate().ToString(); streamVideoSizeOpt.SelectedValue = VLC.getStrmVideoSizeOpt(); if (streamVideoSizeOpt.SelectedValue == "preset") { streamVideoScaleSize.Visible = false; streamVideoSize.Visible = true; } else { streamVideoSizeOpt.SelectedValue = "scale"; streamVideoSize.Visible = false; streamVideoScaleSize.Visible = true; } streamVideoSize.Text = VLC.getStrmVideoSize(); streamVideoScaleSize.Text = VLC.getStrmVideoScale(); streamSetting.SelectedValue = VLC.getStrmSetting(); if (VLC.getStrmSetting() == "manual") { preConfigMessage.Visible = false; manualOptions.Visible = true; strmMux.SelectedValue = VLC.getStrmMux(); strmVideo.SelectedValue = VLC.getStrmVideo(); strmAudio.SelectedValue = VLC.getStrmAudio(); strmAudoBitrate.SelectedValue = VLC.getStrmAudioBitRate(); strmAudioChannels.SelectedValue = VLC.getStrmAudioChannels(); strmVencoder.SelectedValue = VLC.getStrmVEncoder(); if (VLC.getStrmVEncoder() == "h264") { H264.Visible = true; //Web Streamer H264 Video Encoder Class. Instantiate to appropriate profile H264Encoder H264Enc = new H264Encoder(vlcProfile); strmH264KeyInt.Text = H264Enc.getH264KeyInt(); strmH264IDRInt.Text = H264Enc.getH264IDRInt(); strmH264BFrames.Text = H264Enc.getH264BFrames(); strmH264QuantizerParam.Text = H264Enc.getH264QuantizerParam(); strmH264QuantizerMax.Text = H264Enc.getH264QuantizerMax(); strmH264QuantizerMin.Text = H264Enc.getH264QuantizerMin(); strmH264CABAC.Checked = H264Enc.getH264CABAC(); strmH264LoopFilter.Checked = H264Enc.getH264LoopFilter(); strmH264Analyse.Checked = H264Enc.getH264Analyse(); strmH264FrameRef.Text = H264Enc.getH264FrameRef(); strmH264Adapt.Text = H264Enc.getH264Adapt(); strmH264Me.Text = H264Enc.getH264Me(); strmH264SubME.Text = H264Enc.getH264SubME(); strmH264ChromaME.Text = H264Enc.getH264ChromaME(); strmH264MERange.Text = H264Enc.getH264MERange(); } else { H264.Visible = false; } } else { preConfigMessage.Visible = true; manualOptions.Visible = false; H264.Visible = false; } } private int GetVlcProfile() { //Determine if VLC object should be defualted to profile 1(video) or 2(audio) int vlcProfile; if (Request.Params["playerType"] != null) { vlcProfile = Convert.ToInt16(Request.Params["playerType"]); } else { vlcProfile = 1; } return vlcProfile; } protected void startStreamButton_Click(object sender, EventArgs e) { StartStreamTable.Visible = false; transConfigOptions.Visible = false; buttonTable.Visible = true; hlSubmit_Click(null, null); resetButton_Click(null, null); guideParams = Global.Settings; //Instantiate a VLC instance defaulted to correct profile int vlcProfile = GetVlcProfile(); VLCCommon VLC = new VLCCommon(vlcProfile); //Get the server IP string serverIP = Request.ServerVariables["http_host"]; int index = serverIP.IndexOf(":"); if (index > -1) serverIP = serverIP.Substring(0, index).Trim(); if ((serverIP == null) || (serverIP.Length < 1)) serverIP = getIP(); //Create the address the stream will be available on serverAddr = serverIP + ":" + guideParams.strmPort; //Kill any running VLC processes killVLC(); //Start a keepalive routine so window does not timeout AddKeepAlive(); //Process to follow if user wants to use a browser plugin rather than an external player if ((!VLC.strmExternal) && (VLC.strmPlayer != "dnld")) { //Turn off the row of buttons for launching the player or killing the server stream buttonTable.Rows[0].Visible = false; //Turn on the row that contains the button for killing the server stream buttonTable.Rows[1].Visible = true; buttonTable.Rows[1].Cells[0].Visible = true; //If using VLC plugin provide user with controls to stop, play, pause skip back and forward if ((vlcProfile == 1 && guideParams.strmPlayer != "vlc") || (vlcProfile != 1 && guideParams.strmPlayer2 != "vlc")) { controlTable.Visible = false; } else { controlTable.Visible = true; } //Set the parameter variables for the plugin players string vsize = VLC.strmVideoSize; string width = " WIDTH=\"320\""; string heigth = " HEIGHTH=\"213\""; plugin.Text = ""; if (VLC.strmPlayer != "dnld") { //Windows Media Plugin if (VLC.strmPlayer == "wmp") { plugin.Text = " <div align=\"center\">"; plugin.Text = " <EMBED TYPE=\"application/x-mplayer2\""; plugin.Text += " AutoStart=\"false\""; plugin.Text += " NAME=\"video1\""; plugin.Text += " ShowControls=\"1\" ShowStatusBar=\"1\" AutoSize=\"false\" loop=\"false\" EnableContextMenu=\"0\" DisplaySize=\"0\""; plugin.Text += " SRC=\"http://" + serverAddr + "\""; plugin.Text += width; plugin.Text += heigth; plugin.Text += " </EMBED>"; plugin.Text += " </div>"; } //VLC Plugin being displayed in IE else if (Request.ServerVariables["HTTP_USER_AGENT"].IndexOf("MSIE") > 0) { plugin.Text = " <div align=\"center\">"; plugin.Text += " <OBJECT id=\"video1\" codeBase=\"http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab\" " + width + " " + heigth + " classid=\"clsid:E23FE9C6-778E-49D4-B537-38FCDE4887D8\" events=\"True\" >"; plugin.Text += " <PARAM NAME=\"AutoLoop\" VALUE=\"FALSE\">"; plugin.Text += " <PARAM NAME=\"AutoPlay\" VALUE=\"FALSE\">"; plugin.Text += " <PARAM NAME=\"MRL\" VALUE=\"\">"; plugin.Text += " <PARAM NAME=\"ShowDisplay\" VALUE=\"TRUE\">"; plugin.Text += " </OBJECT>"; plugin.Text += " </div>"; //Add Client Script to play the video in IE AddPlayerScript(); } //VLC Plugin being displayed in a non-IE browser else { plugin.Text = " <div align=\"center\">"; plugin.Text += " <embed type=\"application/x-vlc-plugin\" name=\"video1\" autoplay=\"no\" loop=\"no\" " + width + " " + heigth; plugin.Text += " target=\"http://" + serverAddr + "\">"; plugin.Text += " </div>"; //Add Client Script to play the video in non-IE browser AddPlayerScript(); } } //Set the user message telling them what to do streamMessage.Text = "Server is now streaming video. Press Play to begin video. WHEN DONE....Click button to stop the Server Stream."; } //Setup the page for external player usage else { //Turn off the control table since it is not needed controlTable.Visible = false; //Turn on the row of buttons for External Player Launch and Kill Server Process buttonTable.Rows[0].Visible = true; //Turn off the row that only contains the Kill Server Process button buttonTable.Rows[1].Visible = false; //Set the user message telling them what to do streamMessage.Text = "Server is now streaming video. Launch external player to view stream. WHEN DONE....Click button to stop the Server Stream."; } if (VLC.strmPlayer == "dnld") { span3.InnerHtml = "Begin Download"; if (vlcProfile == 1) { streamMessage.Text = "Server is now streaming video. Launch download to save the streaming video. WHEN DONE....Click button to stop the Server Stream."; } else { streamMessage.Text = "Server is now streaming audio. Launch download to save the streaming audio. WHEN DONE....Click button to stop the Server Stream."; } } // kill any existing VLC processes killVLC(); //Start the stream on the server doPlay(); } protected void playerOptsButton_Click(object sender, EventArgs e) { playerOptions.Visible = true; transcodeOptions.Visible = false; hlSubmit_Click(null, null); resetButton_Click(null, null); } protected void transOptsButton_Click(object sender, EventArgs e) { playerOptions.Visible = false; transcodeOptions.Visible = true; if (streamSetting.SelectedValue != "manual") { manualOptions.Visible = false; } else { manualOptions.Visible = true; } hlSubmit_Click(null, null); resetButton_Click(null, null); } protected void hlSubmit_Click(object sender, EventArgs e) { guideParams = Global.Settings; //Determine correct VLC Profile int vlcProfile = GetVlcProfile(); if (vlcProfile != 2) { guideParams.strmPlayer = streamPlayer.Text; guideParams.strmExternal = externalPlayer.Checked; guideParams.strmPort = Convert.ToInt32(streamPort.Text); guideParams.strmBuffer = Convert.ToInt32(streamBuffer.Text); guideParams.strmPriority = streamPriority.Text; guideParams.strmBitRate = Convert.ToInt32(streamBitRate.Text); guideParams.strmVideoSizeOpt = streamVideoSizeOpt.Text; guideParams.strmVideoSize = streamVideoSize.Text; CultureInfo culture = new CultureInfo("en-US"); guideParams.strmVideoScaleSize = String.Format("{0:00.00}", decimal.Parse(streamVideoScaleSize.Text.Replace(',', '.'), NumberStyles.AllowDecimalPoint, culture)).Replace( ',', '.'); streamVideoScaleSize.Text = guideParams.strmVideoScaleSize; if (streamVideoSizeOpt.SelectedValue == "preset") { streamVideoScaleSize.Visible = false; streamVideoSize.Visible = true; } else { streamVideoSize.Visible = false; streamVideoScaleSize.Visible = true; } guideParams.strmSetting = streamSetting.Text; if (streamSetting.Text == "manual") { preConfigMessage.Visible = false; manualOptions.Visible = true; guideParams.strmMux = strmMux.SelectedValue; guideParams.strmVideo = strmVideo.SelectedValue; guideParams.strmAudio = strmAudio.SelectedValue; guideParams.strmAudoBitrate = strmAudoBitrate.SelectedValue; guideParams.strmAudioChannels = strmAudioChannels.SelectedValue; guideParams.strmVEncoder = strmVencoder.SelectedValue; if (strmVencoder.SelectedValue == "h264") { H264.Visible = true; guideParams.strmH264KeyInt = strmH264KeyInt.Text; guideParams.strmH264IDRInt = strmH264IDRInt.Text; guideParams.strmH264BFrames = strmH264BFrames.Text; guideParams.strmH264QuantizerParam = strmH264QuantizerParam.Text; guideParams.strmH264QuantizerMax = strmH264QuantizerMax.Text; guideParams.strmH264QuantizerMin = strmH264QuantizerMin.Text; guideParams.strmH264CABAC = strmH264CABAC.Checked; guideParams.strmH264LoopFilter = strmH264LoopFilter.Checked; guideParams.strmH264Analyse = strmH264Analyse.Checked; guideParams.strmH264FrameRef = strmH264FrameRef.Text; guideParams.strmH264Adapt = strmH264Adapt.Text; guideParams.strmH264Me = strmH264Me.Text; guideParams.strmH264SubME = strmH264SubME.Text; guideParams.strmH264ChromaME = strmH264ChromaME.Text; guideParams.strmH264MERange = strmH264MERange.Text; } else { H264.Visible = false; } } else { preConfigMessage.Visible = true; manualOptions.Visible = false; H264.Visible = false; } } else { guideParams.strmPlayer2 = streamPlayer.Text; guideParams.strmExternal2 = externalPlayer.Checked; guideParams.strmPort2 = Convert.ToInt32(streamPort.Text); guideParams.strmBuffer2 = Convert.ToInt32(streamBuffer.Text); guideParams.strmPriority2 = streamPriority.Text; guideParams.strmBitRate2 = Convert.ToInt32(streamBitRate.Text); guideParams.strmVideoSizeOpt2 = streamVideoSizeOpt.Text; guideParams.strmVideoSize2 = streamVideoSize.Text; CultureInfo culture = new CultureInfo("en-US"); guideParams.strmVideoScaleSize2 = String.Format("{0:00.00}", decimal.Parse(streamVideoScaleSize.Text.Replace(',', '.'), NumberStyles.AllowDecimalPoint, culture)).Replace( ',', '.'); streamVideoScaleSize.Text = guideParams.strmVideoScaleSize2; if (streamVideoSizeOpt.SelectedValue == "preset") { streamVideoScaleSize.Visible = false; streamVideoSize.Visible = true; } else { streamVideoSize.Visible = false; streamVideoScaleSize.Visible = true; } guideParams.strmSetting2 = streamSetting.Text; if (streamSetting.Text == "manual") { preConfigMessage.Visible = false; manualOptions.Visible = true; guideParams.strmMux2 = strmMux.SelectedValue; guideParams.strmVideo2 = strmVideo.SelectedValue; guideParams.strmAudio2 = strmAudio.SelectedValue; guideParams.strmAudoBitrate2 = strmAudoBitrate.SelectedValue; guideParams.strmAudioChannels2 = strmAudioChannels.SelectedValue; guideParams.strmVEncoder2 = strmVencoder.SelectedValue; if (strmVencoder.SelectedValue == "h264") { H264.Visible = true; guideParams.strmH264KeyInt2 = strmH264KeyInt.Text; guideParams.strmH264IDRInt2 = strmH264IDRInt.Text; guideParams.strmH264BFrames2 = strmH264BFrames.Text; guideParams.strmH264QuantizerParam2 = strmH264QuantizerParam.Text; guideParams.strmH264QuantizerMax2 = strmH264QuantizerMax.Text; guideParams.strmH264QuantizerMin2 = strmH264QuantizerMin.Text; guideParams.strmH264CABAC2 = strmH264CABAC.Checked; guideParams.strmH264LoopFilter2 = strmH264LoopFilter.Checked; guideParams.strmH264Analyse2 = strmH264Analyse.Checked; guideParams.strmH264FrameRef2 = strmH264FrameRef.Text; guideParams.strmH264Adapt2 = strmH264Adapt.Text; guideParams.strmH264Me2 = strmH264Me.Text; guideParams.strmH264SubME2 = strmH264SubME.Text; guideParams.strmH264ChromaME2 = strmH264ChromaME.Text; guideParams.strmH264MERange2 = strmH264MERange.Text; } else { H264.Visible = false; } } else { preConfigMessage.Visible = true; manualOptions.Visible = false; H264.Visible = false; } } Global.Settings.Save(); } private void getTheme() { string theme = Convert.ToString(Session["theme"]); if (theme != null && theme != "") { return; } else { HttpCookie cookie = Request.Cookies["theme"]; if (cookie != null && cookie.Value.Length > 0) { theme = cookie.Value; } else { theme = "Default"; } Session["theme"] = "themes/" + theme; return; } } protected void streamPlayer_SelectedIndexChanged(object sender, EventArgs e) { if (IsPostBack) { if (streamPlayer.SelectedValue == "dnld") { string holdSelection = streamSetting.SelectedValue; setDownloadTransOptions(); try { streamSetting.SelectedValue = holdSelection; } catch { streamSetting.Items[0].Selected = true; } hlSubmit_Click(null, null); } else { string holdSelection = streamSetting.SelectedValue; setNonDownloadTransOptions(); try { streamSetting.SelectedValue = holdSelection; } catch { streamSetting.Items[0].Selected = true; } hlSubmit_Click(null, null); } } } private void setDownloadTransOptions() { streamSetting.Items.Clear(); streamSetting.Items.Add("MP4V/MPGA/MPEG-TS"); streamSetting.Items[0].Value = "dvs0"; streamSetting.Items[0].Selected = true; streamSetting.Items.Add("MP2V/MPGA/MPEG-TS"); streamSetting.Items[1].Value = "dvs1"; streamSetting.Items.Add("MP1V/MPGA/MPEG-TS"); streamSetting.Items[2].Value = "dvs2"; streamSetting.Items.Add("Manual Options"); streamSetting.Items[3].Value = "manual"; } private void setNonDownloadTransOptions() { streamSetting.Items.Clear(); streamSetting.Items.Add("MP4V/MP4A/MPEG-TS"); streamSetting.Items[0].Value = "0"; streamSetting.Items.Add("WMV/MP4A/MPEG-TS"); streamSetting.Items[1].Value = "1"; streamSetting.Items.Add("WMV/MP3/ASF"); streamSetting.Items[2].Value = "2"; streamSetting.Items.Add("H264/MP4A/MPEG-TS"); streamSetting.Items[3].Value = "3"; streamSetting.Items.Add("Manual Options"); streamSetting.Items[4].Value = "manual"; } protected void externalPlayer_CheckedChanged(object sender, EventArgs e) { if (IsPostBack) { hlSubmit_Click(null, null); resetButton_Click(null, null); } } } }